package com.petRescueCenter.demo.common.web;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@JsonInclude(value=Include.NON_EMPTY)
public class VueResponse {
	private boolean success= true;
	private String msg= "";
	
	private Map<String,Object> map;
	
	public VueResponse() {}
	
	public VueResponse(boolean success) {
		this.success = success;
	}
	
	public VueResponse(boolean success,String msg) {
		this.success = success;
		this.msg = msg;
	}
	
	public VueResponse(boolean success,Map<String,Object> map) {
		this.success = success;
		this.map = map;
	}
	
	public boolean isSuccess() {
		return success;
	}
	public String getMsg() {
		return msg;
	}

	public Map<String, Object> getMap() {
		return map;
	}	
	
	/**
	 * 获取一个错误异步返回
	 * */
	public static Map<String,Object> getErrerResponse(String errMsg) {
		Map<String,Object> map = new HashMap<>();
		map.put("success", false);
		map.put("msg", errMsg);
		return map;
	}
	/**
	 * 获取一个带错误代码的错误异步返回
	 * */
	public static Map<String,Object> getErrerResponse(String errCode,String errMsg) {
		Map<String,Object> map = new HashMap<>();
		map.put("success", false);
		map.put("msg", errMsg);
		map.put("errCode", errCode);
		return map;
	}
	
	/**
	 * 获取一个成功异步返回
	 * */
	public static Map<String,Object> getSuccessResponse(String msg) {
		Map<String,Object> map = new HashMap<>();
		map.put("success", true);
		map.put("msg", msg);
		return map;
	}
	
	/**
	 * 获取一个成功异步返回
	 * */
	public static Map<String,Object> getSuccessResponse() {
		Map<String,Object> map = new HashMap<>();
		map.put("success", true);
		map.put("msg", "执行成功");
		return map;
	}
	
	/**
	 * 获取一个带数据的成功异步返回
	 * */
	public static Map<String,Object> getSuccessResponse(String msg,Object content) {
		Map<String,Object> map = new HashMap<>();
		map.put("success", true);
		map.put("msg", msg);
		map.put("content", content);
		return map;
	}
	
	
	
	
	
	
	
	
	
	
	
}
